package classes;

import interfaces.Atacante;
import interfaces.Defensor;
import interfaces.Posicionable;

public abstract class Persona implements Defensor, Atacante, Posicionable{
	private int energia = 100;
	private Posicion position;
	private int PATK;
	private int rangoAtk = 1;
	private Rect size = new Rect();

	public void atacarA(Defensor d) {
		// Si el objetivo esta dentro del rango, atacarlo
		if(Posicion.distancia(d.getPosition(), this.getPosition()) <= this.getRangoAtk()){
			d.teAtaca(this);
		}
	}
	
	public int getRangoAtk() {
		return rangoAtk;
	}
	
	public int getEnergia() {
		return energia;
	}
	public void setEnergia(int energia) {
		this.energia = energia;
	}
	public Posicion getPosition() {
		return position;
	}
	public void setPosition(Posicion position) {
		this.position = position;
	}
	public int getPATK() {
		return PATK;
	}
	public void setPATK(int pATK) {
		PATK = pATK;
	}

	public Rect getSize() {
		return size;
	}
	
	public void setSize(Rect size) {
		this.size = size;
	}

	public boolean ocupa(Posicion p) {
		return this.size.ocupa(p);
	}

	public void teAtaca(Atacante a) {
		this.energia -= a.getPATK();
	}
	
}
